/****************************************************
	文件：ReactivePropertyExample.cs
	作者：HuskyT
	邮箱：1005240602@qq.com
	日期：2020/5/15 21:46:48
	功能：响应式属性 小例子
*****************************************************/

using System;
using UnityEngine;

namespace HTUtility.Example
{
    public class ReactivePropertyExample : MonoBehaviour
    {
        private PlayerData mplayerData;
        private void Start()
        {
            mplayerData = new PlayerData();
            mplayerData.Hp = new ReactiveProperty<float>(100);
            BattleModule.Init(mplayerData);
            mplayerData.Hp.Subscribe(v =>
            {
                Debug.Log("血量变为：" + v);
            });
            mplayerData.Hp.Value += 20.0f;
        }

        public class PlayerData
        {
            public ReactiveProperty<float> Hp;
        }
        public class BattleModule
        {
            public static void Init(PlayerData pd)
            {
                pd.Hp.Subscribe(v =>
                {
                    Debug.Log("战斗使血量变为：" + v);
                });
            }
        }
    }
}
